package pojo;


import com.fasterxml.jackson.annotation.JsonFormat;

import java.sql.Timestamp;
import java.text.SimpleDateFormat;

public class Order {

  private Integer orderId;
  private Integer tableId;
  @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
  private Timestamp orderCreateTime;
  @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
  private Timestamp orderPayTime;
  private Double orderMoney;
  private Integer orderIsMember;
  private String orderMemberName;
  private String orderWorkerName;

  private TableInfo tableInfo;
  private OrderFood orderFood;
  private OrderFoodBk orderFoodBk;
  private Integer page;
  private Integer limit;

  public Integer getPage() {
    return page;
  }

  public void setPage(Integer page) {
    this.page = page;
  }

  public Integer getLimit() {
    return limit;
  }

  public void setLimit(Integer limit) {
    this.limit = limit;
  }

  public String getOrderMemberName() {
    return orderMemberName;
  }

  public void setOrderMemberName(String orderMemberName) {
    this.orderMemberName = orderMemberName;
  }

  public String getOrderWorkerName() {
    return orderWorkerName;
  }

  public void setOrderWorkerName(String orderWorkerName) {
    this.orderWorkerName = orderWorkerName;
  }

  public Integer getOrderIsMember() {
    return orderIsMember;
  }

  public void setOrderIsMember(Integer orderIsMember) {
    this.orderIsMember = orderIsMember;
  }

  public OrderFoodBk getOrderFoodBk() {
    return orderFoodBk;
  }

  public void setOrderFoodBk(OrderFoodBk orderFoodBk) {
    this.orderFoodBk = orderFoodBk;
  }

  public TableInfo getTableInfo() {
    return tableInfo;
  }

  public void setTableInfo(TableInfo tableInfo) {
    this.tableInfo = tableInfo;
  }

  public OrderFood getOrderFood() {
    return orderFood;
  }

  public void setOrderFood(OrderFood orderFood) {
    this.orderFood = orderFood;
  }

  public Timestamp getOrderCreateTime() {
    return orderCreateTime;
  }

  public void setOrderCreateTime(Timestamp orderCreateTime) {
    this.orderCreateTime = orderCreateTime;
  }

  public String getOrderPayTime() {
    /*if (orderPayTime == null) return null;
    DateFormat dateFormat = DateFormat.getDateInstance();
    return dateFormat.format(this.orderPayTime);*/
    if (orderPayTime == null) return null;
    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    return df.format(orderPayTime);
  }

  public void setOrderPayTime(String orderPayTime) {
    if (orderPayTime == null || "".equals(orderPayTime.trim())) {
      this.orderPayTime = null;
    } else {
      try {
       /* DateFormat dateFormat = DateFormat.getDateInstance();
        this.orderPayTime = new java.sql.Timestamp(dateFormat.parse(orderPayTime).getTime());*/
        Timestamp ts = Timestamp.valueOf(orderPayTime);
        this.orderPayTime = ts;
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  }
  
  public Integer getOrderId() {
    return orderId;
  }

  public void setOrderId(Integer orderId) {
    this.orderId = orderId;
  }


  public Integer getTableId() {
    return tableId;
  }

  public void setTableId(Integer tableId) {
    this.tableId = tableId;
  }

  public Double getOrderMoney() {
    return orderMoney;
  }

  public void setOrderMoney(Double orderMoney) {
    this.orderMoney = orderMoney;
  }

  @Override
  public String toString() {
    return "Order{" +
            "orderId=" + orderId +
            ", tableId=" + tableId +
            ", orderCreateTime=" + orderCreateTime +
            ", orderPayTime=" + orderPayTime +
            ", orderMoney=" + orderMoney +
            ", orderIsMember=" + orderIsMember +
            ", orderMemberName=" + orderMemberName +
            ", orderWorkerName=" + orderWorkerName +
            ", tableInfo=" + tableInfo +
            ", orderFood=" + orderFood +
            ", orderFoodBk=" + orderFoodBk +
            ", page=" + page +
            ", limit=" + limit +
            '}';
  }
}
